//求和功能相关配置
const countOptions = {
    namespaced: true,
    //actions用于响应组件的动作
    actions: {
        jiaOdd(context, value) {
            if (context.state.sum % 2) {
                context.commit("JIA", value);
            }
        },
        jiaWait(context, value) {
            setTimeout(() => {
                context.commit("JIA", value);
            }, 500);
        },
    },

    //mutations用于操作数据(state)
    mutations: {
        JIA(state, value) {
            state.sum += value;
        },
        JIAN(state, value) {
            state.sum -= value;
        },
    },

    //state用于存储数据
    state: {
        sum: 0,
        school: "尚硅谷",
        subject: "前端",
    },

    //getters用于将state中的数据进行加工
    getters: {
        bigSum(state) {
            return state.sum * 10;
        }
    },
}

export default countOptions;